<?php
/**
*
* 功能描述（日志数据）
*
* @author suoya <jlusuoya@gmail.com>
* @version 1
*/

class ModelLog extends ModelBase
{
	function NewLog($userid, $type, $dataid, $param, $desp)
	{
		$data = array(
			'userid' => $userid,
			'logtype' => $type,
			'dataid' => $dataid,
			'param' => $param,
			'desp' => $desp,
		);
		$id = $this->db->Insert("core_log", $data);
	}

	function GetLogList($page)
	{
		$data  = $this->db->getRow("core_log", 'count(1) cnt', "1");
		if($data['cnt'] == 0)
			return array('cnt' => 0, 'pageCnt' => 0, 'data' => array());

		$retData = array('cnt' => $data['cnt'], 'pageCnt' => ceil($data['cnt'] / ADM_PAGESIZE));
		$limit = ADM_PAGESIZE * ($page - 1) . ", " . ADM_PAGESIZE;
		$data = $this->db->getAll("core_log", "userid, logtime, logtype, dataid, param, desp", "1", 'logtime desc', $limit);
		$retData['data'] = $data;
		return $retData;
	}
}

